Skip to content

Conversation

devshgraphicsprogramming
Copy link
Member

@devshgraphicsprogramming devshgraphicsprogramming commented Sep 16, 2025

Description

Continues #899 , #916 and #919

Testing

TODO list:

Comment on lines +97 to +122
#ifndef __HLSL_VERSION
namespace std
{
template<typename T, uint16_t N>
struct hash<nbl::hlsl::vector<T,N> >
{
size_t operator()(const nbl::hlsl::vector<T,N>& v) const noexcept
{
size_t seed = 0;
NBL_UNROLL for (uint16_t i = 0; i < N; i++)
nbl::core::hash_combine(seed, v[i]);
return seed;
}
};

template<typename T>
struct hash<nbl::hlsl::vector<T,1> >
{
size_t operator()(const nbl::hlsl::vector<T,1>& v) const noexcept
{
std::hash<T> hasher;
return hasher(v.x);
}
};
}
#endif
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure having this specialization globally is a good idea ?

What do you use it for ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also used in the bucket bxdf test, for hash map buckets

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then define it in that example, nowhere else

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this over from the test due to this comment
Devsh-Graphics-Programming/Nabla-Examples-and-Tests#165 (comment)

Comment on lines 167 to 174
N ndf;
F fresnel;
};

template<class Config, class N, class F>
NBL_PARTIAL_REQ_TOP(config_concepts::MicrofacetConfiguration<Config> && ndf::NDF<N> && fresnel::Fresnel<F>)
struct SCookTorrance<Config, N, F, true NBL_PARTIAL_REQ_BOT(config_concepts::MicrofacetConfiguration<Config> && ndf::NDF<N> && fresnel::Fresnel<F>) >
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance at inheriting from a common base for both BRDF and BSDF, so that we don't have so much duplicate code (BRDF and BSDF only differ in how they factor the reflectance into the generation and pdf)

Comment on lines 39 to 48
static this_t create(scalar_type A, NBL_CONST_REF_ARG(spectral_type) eta, NBL_CONST_REF_ARG(spectral_type) etak)
{
this_t retval;
retval.__base.ndf.__base.A = vector2_type(A, A);
retval.__base.ndf.__base.a2 = A*A;
retval.__base.fresnel.ior = ior0;
retval.__base.fresnel.iork = ior1;
retval.__base.fresnel.iork2 = ior1*ior1;
retval.__base.fresnel.eta = eta;
retval.__base.fresnel.etak2 = etak * etak;
retval.__base.fresnel.etaLen2 = eta * eta + retval.__base.fresnel.etak2;
return retval;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you assuming the fresnel used ?

Comment on lines -45 to -46
spectral_type ior0;
spectral_type ior1;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to pass the fresnel already set up

return create(params.A, params.ior0, params.ior1);
return create(params.A, params.eta, params.etak);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do all these still exist and aren't just typedefs for Cook Torrance ?

Comment on lines 36 to 43
sample_type generate(NBL_CONST_REF_ARG(isotropic_interaction_type) interaction, const vector2_type u)
{
return __base.generate(anisotropic_interaction_type::create(interaction), u);
return __base.template generate<vector2_type>(anisotropic_interaction_type::create(interaction), u);
}
sample_type generate(NBL_CONST_REF_ARG(anisotropic_interaction_type) interaction, const vector2_type u)
{
return __base.generate(interaction, u);
return __base.template generate<vector2_type>(interaction, u);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just typedef instead of writing pointless passthrough class ?

{
quant_type G2 = ndf.template correlated<sample_type, isotropic_interaction_type>(gq, qq, _sample, interaction);
DG *= G2.microfacetMeasure;
DG *= ndf.template correlated<sample_type, isotropic_interaction_type>(gq, _sample, interaction);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lower the gq creation as well

{
quant_type G2 = ndf.template correlated<sample_type, anisotropic_interaction_type>(gq, qq, _sample, interaction);
DG *= G2.microfacetMeasure;
DG *= ndf.template correlated<sample_type, anisotropic_interaction_type>(gq, _sample, interaction);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lower the gq creation as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants